#include<bits/stdc++.h>
using namespace std;
int n,m,l,mv;
int d[10001];
int v[10001];
int a[10001];
int p[10001];
int de[10001];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
    vector<int>vis[10001];
    memset(d,0,sizeof(d));
    memset(v,0,sizeof(v));
    memset(a,0,sizeof(a));
    memset(p,0,sizeof(p));
    memset(de,0,sizeof(de));
    cin>>n>>m>>l>>mv;
    for(int i=1;i<=n;i++){
        cin>>d[i]>>v[i]>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>p[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        int best=ans+1;
        for(int j=1;j<=m;j++){
            int dis=p[j]-d[i];
            if(p[j]<d[i])continue;
            int v1=2*dis*a[i]+v[i]*v[i];
            int sv1=sqrt(v1);
            if(sv1*sv1==v1){
                if(sv1>mv){
                    de[i]+=1;
                    ans=best;
                    vis[j].push_back(i);
                }
            }
            else{
                if(sv1>=mv){
                    de[i]+=1;
                    ans=best;
                    vis[j].push_back(i);
                }
            }
        }
    }
    int sum=0;
    for(int j=1;j<=m;j++){
        bool f=1;
        if(vis[j].size()==0){
            sum++;
            f=0;
            continue;
        }
        for(int p1=0;p1<vis[j].size();p1++){
            if(de[vis[j][p1]]==1){
                f=0;
            }
        }
        if(f==1){
        sum++;
        for(int p1=0;p1<vis[j].size();p1++){
            de[vis[j][p1]]--;
        }
        }
    }
    cout<<ans<<" "<<sum<<endl;
    }
    return 0;
}
